package com.jxw.cloudpen.web.netty.websocketclient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

public class client2 {

//    @Autowired
//    private RestTemplate restTemplate;

    public static void main(String[] args) {
        System.out.println(registerUser());
    }
    public static String registerUser() {
        String url = "https://api-test.xuewangketang.com/api/tms/api/Book/list?isbn=&name=&phase=2pg21B&subject=W3g3M5&grade=29TMBX&publisher=3UVBA5&volume=80u5sP";
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.add("Authorization","Bearer e911f162-3068-4df4-be18-cd5af556f2be");
        headers.add("Tenant-Id","1");
        headers.add("Client-Toc","Y");
        // 创建一个请求体，包含 JSON 数据
        String jsonBody = String.format("{\n" +
                "\t\"current\": 1,\n" +
                "\t\"size\": 10,\n" +
                "\t\"difficulty\": 2\n" +
                "}");
//        HttpEntity<String> entity = new HttpEntity<>(jsonBody, headers);
        HttpEntity<String> entity = new HttpEntity<>(headers);
        // 发送 POST 请求
        return new RestTemplate().exchange(url, HttpMethod.GET, entity, String.class).getBody();
    }
}
